/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package UI;

import java.io.Serializable;
import java.util.Date;

/**
 *
 * @author Mathias
 */
public class ChatMessageUI implements Serializable {
    private static final long serialVersionUID = 1L;
    private String message;
    private String sender;
    private Integer id;
    private Date timesent;
    private ChatUI chat;

    public ChatMessageUI() {
    }

    public ChatMessageUI(String message, String sender, Date timesent, ChatUI chat) {
        this.message = message;
        this.sender = sender;
        
        this.timesent = timesent;
        this.chat = chat;
    }

    public ChatMessageUI(String message, String sender, Integer id, Date timesent, ChatUI chat) {
        this.message = message;
        this.sender = sender;
        this.id = id;
        this.timesent = timesent;
        this.chat = chat;
    }

    public ChatUI getChat() {
        return chat;
    }

    public void setChat(ChatUI chat) {
        this.chat = chat;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }


    public String getSender() {
        return sender;
    }

    public void setSender(String sender) {
        this.sender = sender;
    }

    public Date getTimesent() {
        return timesent;
    }

    public void setTimesent(Date timesent) {
        this.timesent = timesent;
    }
    
    
    public String getModifiedDateString(){
        String month = null;
        String hour = null;
        String day = null;
        String minute = null;
        int monthint = timesent.getMonth() + 1;
        int yearint = timesent.getYear() + 1900;
        if (monthint < 10) {
            month = "0" + monthint;
        } else {
            month = "" + monthint;
        }

        if (timesent.getDate() < 10) {
            day = "0" + timesent.getDate();
        } else {
            day = "" + timesent.getDate();
        }


        if (timesent.getHours() < 10) {
            hour = "0" + timesent.getHours();
        } else {
            hour = "" + timesent.getHours();
        }
        
        if (timesent.getMinutes() < 10) {
            minute = "0" + timesent.getMinutes();
        } else {
            minute = "" + timesent.getMinutes();
        }



        String string = new String("" + yearint + "-" + month +"-" + day + " " + hour + ":" + minute);

        return string;
    }
    
}
